<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="keywords" content="admin, dashboard, bootstrap, template, flat, modern, theme, responsive, fluid, retina, backend, html5, css, css3">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">

  <title>{:lang("编辑菜单")}</title>
  
  <!--common-->
  <link href="/static/css/public/style.css" rel="stylesheet">
  <link href="/static/css/public/style-responsive.css" rel="stylesheet">
  
  <!--file upload-->
  <link rel="stylesheet" type="text/css" href="/static/css/public/bootstrap-fileupload.min.css" />
  

 

  <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <script src="js/respond.min.js"></script>
  <![endif]-->
</head>

<body class="sticky-header">
	<!-- 左侧菜单开始-->
	{include file="public/nav_left"}
    <!-- 左侧菜单结束-->
    
    <!-- main content start-->
    <div class="main-content" >

        <!-- 头部菜单开始-->
          {include file="public/nav_top"}
        <!-- 头部菜单结束-->
        
        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                {:lang("编辑菜单")}
            </h3>
        </div>
        <!-- page heading end-->

        <!--主内容开始-->
        <div class="wrapper">
        
          <div class="row">
            <div class="col-lg-12">
                <section class="panel">
                    <header class="panel-heading">
                        {:lang("编辑菜单")}
                    </header>
                    <div class="panel-body">
                        <form  id="form" action="/admin/Menu/saveMenuData" class="form-horizontal adminex-form" role="form" method="post" enctype="multipart/form-data">
                                                 
                            <input type="hidden" id="id" name="id" value="{$data['id']|default=0}"> 
                        
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">{:lang("菜单名称")}</label>
                                <div class="col-sm-10">
                                    <input type="text" id="menu_name" name="menu_name" class="form-control" value="{$data['menu_name']|default=''}" required >
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">{:lang("菜单链接")}</label>
                                <div class="col-sm-10">
                                    <input type="text" id="menu_url" name="menu_url" class="form-control" value="{$data['menu_url']|default=''}" required >
                                </div>
                            </div>
                            
                          
                            
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">{:lang("菜单级别")}</label>
                                <div class="col-sm-10">
                                    <select id="menu_level" name="menu_level" class="form-control m-bot15" onChange="getParentMenu()" >
                                    {volist name="list" id="vo"}
                                    <option value ="{$vo.data_id}" {if condition="(isset($data)) AND ($vo.data_id == $data['menu_level'])"} selected = "selected" {/if} >{:lang($vo.data_name)}</option>
                                    {/volist}
                                    </select>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">{:lang("上级菜单")}</label>
                                <div class="col-sm-10">
                                    <select id="parent_id" name="parent_id" class="form-control m-bot15">
                                    {if condition="isset($data['id']) && $data['parent_id'] neq 0"}
                                    <option value ="{$data['parent_id']}" >{$data['parent_name']}</option>
                                    {else /}
                                    <option value ="0" >无</option>
                                    {/if}
                                    </select>
                                </div>
                            </div>
                            
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">{:lang("排序")}</label>
                                <div class="col-sm-10">
                                    <input type="text" id="sort" name="sort" class="form-control" value="{$data['sort']|default=''}" required >
                                </div>
                            </div>
                            <div style="text-align: center; padding-top: 15px;">
                                <button type="submit" class="btn btn-primary">{:lang("提交")}</button>
                                <button type="button" onClick="history.go(-1)" class="btn btn-primary">{:lang("返回")}</button>
                            </div>
                        </form>
                    </div>
                </section>
            </div>
          </div>
        </div>
        <!--主内容结束-->
    </div>
    <!-- main content end-->

<!-- Placed js at the end of the document so the pages load faster -->
<script src="/static/js/public/jquery-1.10.2.min.js"></script>
<script src="/static/js/public/jquery-ui-1.9.2.custom.min.js"></script>
<script src="/static/js/public/jquery-migrate-1.2.1.min.js"></script>
<script src="/static/js/public/bootstrap.min.js"></script>
<script src="/static/js/public/modernizr.min.js"></script>
<script src="/static/js/public/jquery.nicescroll.js"></script>
<script src="/static/js/public/layer.js"></script>

<script src="/static/js/public/jquery.form.js"></script>

<!--common scripts for all pages-->
<script src="/static/js/public/scripts.js"></script>

<!--file upload-->
<script>
    $("#form").submit(function(){
        var loading = layer.load(1, {shade: [0.3,'#3F3F3F'] });
        $(this).ajaxSubmit({
            success:function(data){
                layer.close(loading);
                if (data.status === 1) {
                    layer.alert(data.msg, function(){
                        location.href="/admin/Menu/getMenuList";
                    });
                } else {
                    layer.msg(data.msg);
                }
            }
        });
        return false;
    });

    //获得上级区域
    function getParentMenu() {
        var menu_level = $("#menu_level").val();
        $.post("/admin/Menu/getParentMenu",{id:menu_level},function(data){
            $("#parent_id").html('');
            if (data.length > 0) {
                for(var i in data ){
                    $("#parent_id").append('<option value ="'+data[i].id+'">'+ data[i].menu_name +'</option>');
                }
            } else {
                $("#parent_id").append('<option value ="0">'+ '无'+'</option>');
            }
        });
    }
</script>
</body>
</html>
